'use strict';
var calculate_median = function(collection){
    
    let median;
    let arr = collection.filter(function(x){
        if(collection.indexOf(x)%2!=0) 
            return x;
    })
    if(arr.length%2==0){
        median = ( arr[arr.length/2-1] + arr[arr.length/2] ) / 2;
    }
    else
        median = arr[parseInt(arr.length/2)];
    return median;
};
module.exports = calculate_median;
